/**
 * @author YinHang
 */
;(function () {
	var g2d = Gamepackage.get("Gamepackage.ui.g2d");
	g2d.Canvas = function (canvas, width, height) {
		this.graphics = new g2d.Graphics(canvas.getContext("2d"));
		this.canvas = canvas;
		this.setWidth(width);
		this.setHeight(height);
	};
	
	Gamepackage.extend(g2d.Canvas, g2d.Displayable);
	var Prototype = g2d.Canvas.prototype;
	
	Prototype.setWidthSuper = Prototype.setWidth;
	Prototype.setHeightSuper = Prototype.setHeight;
	
	Prototype.setWidth = function (width) {
		this.setWidthSuper(width);
		this.canvas.width = width;
	};
	
	Prototype.setHeight = function (height) {
		this.setHeightSuper(height);
		this.canvas.height = height;
	};
	
	Prototype.getGraphics = function () {
		return this.graphics;
	};
	
	Prototype.getSourceCanvas = function () {
		return this.canvas;
	};

	Prototype.draw = function (graphics) {
		graphics.drawCanvas(this, this.x, this.y, this.width, this.height);
	};	
})();
